Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Lock (computer science)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Lock_(computer_science)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Lock_computer_science rootpage-Lock_computer_science skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Lock (computer science)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>In <a href="Computer_science" title="Computer science">computer science</a>, a <b>lock</b> or <b>mutex</b> (from <a href="Mutual_exclusion" title="Mutual exclusion">mutual exclusion</a>) is a <a href="Synchronization_primitive" class="mw-redirect" title="Synchronization primitive">synchronization primitive</a> that prevents state from being modified or accessed by multiple <a href="Threads_(computer_science)" class="mw-redirect" title="Threads (computer science)">threads of execution</a> at once. Locks enforce mutual exclusion <a href="Concurrency_control" title="Concurrency control">concurrency control</a> policies, and with a variety of possible methods there exist multiple unique implementations for different applications.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Types">Types</h2></div>
<p>Generally, locks are <i>advisory locks</i>, where each thread cooperates by acquiring the lock before accessing the corresponding data. Some systems also implement <i>mandatory locks</i>, where attempting unauthorized access to a locked resource will force an <a href="Exception_handling" title="Exception handling">exception</a> in the entity attempting to make the access.
</p><p>The simplest type of lock is a binary <a href="Semaphore_(programming)" title="Semaphore (programming)">semaphore</a>. It provides exclusive access to the locked data. Other schemes also provide shared access for reading data. Other widely implemented access modes are exclusive, intend-to-exclude and intend-to-upgrade.
</p><p>Another way to classify locks is by what happens when the lock strategy prevents the progress of a thread. Most locking designs <a href="Blocking_(computing)" title="Blocking (computing)">block</a> the <a href="Execution_(computers)" class="mw-redirect" title="Execution (computers)">execution</a> of the <a href="Thread_(computer_science)" class="mw-redirect" title="Thread (computer science)">thread</a> requesting the lock until it is allowed to access the locked resource. With a <a href="Spinlock" title="Spinlock">spinlock</a>, the thread simply waits ("spins") until the lock becomes available. This is efficient if threads are blocked for a short time, because it avoids the overhead of operating system process rescheduling. It is inefficient if the lock is held for a long time, or if the progress of the thread that is holding the lock depends on preemption of the locked thread.
</p><p>Locks typically require hardware support for efficient implementation. This support usually takes the form of one or more <a href="Atomic_(computer_science)" class="mw-redirect" title="Atomic (computer science)">atomic</a> instructions such as "<a href="Test-and-set" title="Test-and-set">test-and-set</a>", "<a href="Fetch-and-add" title="Fetch-and-add">fetch-and-add</a>" or "<a href="Compare-and-swap" title="Compare-and-swap">compare-and-swap</a>". These instructions allow a single process to test if the lock is free, and if free, acquire the lock in a single atomic operation.
</p><p><a href="Uniprocessor" class="mw-redirect" title="Uniprocessor">Uniprocessor</a> architectures have the option of using uninterruptible sequences of instructions—using special instructions or instruction prefixes to disable <a href="Interrupt" title="Interrupt">interrupts</a> temporarily—but this technique does not work for <a href="Multiprocessor" class="mw-redirect" title="Multiprocessor">multiprocessor</a> shared-memory machines. Proper support for locks in a multiprocessor environment can require quite complex hardware or software support, with substantial <a href="Synchronization_(computer_science)" title="Synchronization (computer science)">synchronization</a> issues.
</p><p>The reason an <a href="Atomic_operation" class="mw-redirect" title="Atomic operation">atomic operation</a> is required is because of concurrency, where more than one task executes the same logic. For example, consider the following <a href="C_(programming_language)" title="C (programming language)">C</a> code:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">lock</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// lock free, set it</span>
<span class="w"> </span><span class="n">lock</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">myPID</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The above example does not guarantee that the task has the lock, since more than one task can be testing the lock at the same time. Since both tasks will detect that the lock is free, both tasks will attempt to set the lock, not knowing that the other task is also setting the lock. <a href="Dekker's_algorithm" title="Dekker's algorithm">Dekker's</a> or <a href="Peterson's_algorithm" title="Peterson's algorithm">Peterson's algorithm</a> are possible substitutes if atomic locking operations are not available.
</p><p>Careless use of locks can result in <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlock</a> or <a href="Livelock" class="mw-redirect" title="Livelock">livelock</a>. A number of strategies can be used to avoid or recover from deadlocks or livelocks, both at design-time and at <a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run-time</a>. (The most common strategy is to standardize the lock acquisition sequences so that combinations of inter-dependent locks are always acquired in a specifically defined "cascade" order.)
</p><p>Some languages do support locks syntactically. An example in <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> follows:
</p>
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span class="k">public</span><span class="w"> </span><span class="k">class</span><span class="w"> </span><span class="nc">Account</span><span class="w"> </span><span class="c1">// This is a monitor of an account</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// Use `object` in versions earlier than C# 13</span>
<span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="k">readonly</span><span class="w"> </span><span class="n">Lock</span><span class="w"> </span><span class="n">_balanceLock</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="p">();</span>
<span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="kt">decimal</span><span class="w"> </span><span class="n">_balance</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>

<span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Deposit</span><span class="p">(</span><span class="kt">decimal</span><span class="w"> </span><span class="n">amount</span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// Only one thread at a time may execute this statement.</span>
<span class="w"> </span><span class="k">lock</span><span class="w"> </span><span class="p">(</span><span class="n">_balanceLock</span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">_balance</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">amount</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>

<span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Withdraw</span><span class="p">(</span><span class="kt">decimal</span><span class="w"> </span><span class="n">amount</span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// Only one thread at a time may execute this statement.</span>
<span class="w"> </span><span class="k">lock</span><span class="w"> </span><span class="p">(</span><span class="n">_balanceLock</span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">_balance</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="n">amount</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>C# introduced <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */


.mw-parser-output .monospaced{font-family:monospace,monospace}


/* end https://en.wikipedia.org/ */
</style><span class="monospaced">System.Threading.Lock</span> in C# 13 on <a href=".NET" title=".NET">.NET</a> 9.
</p><p>The code <code>lock(this)</code> can lead to problems if the instance can be accessed publicly.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p><p>Similar to <a href="Java_(programming_language)" title="Java (programming language)">Java</a>, C# can also synchronize entire methods, by using the MethodImplOptions.Synchronized attribute.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span class="na">[MethodImpl(MethodImplOptions.Synchronized)]</span>
<span class="k">public</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">SomeMethod</span><span class="p">()</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// do stuff</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Granularity">Granularity</h2></div>
<p>Before being introduced to lock granularity, one needs to understand three concepts about locks:
</p>
<ul><li><i>lock overhead</i>: the extra resources for using locks, like the memory space allocated for locks, the CPU time to initialize and destroy locks, and the time for acquiring or releasing locks. The more locks a program uses, the more overhead associated with the usage;</li>
<li><i>lock <a href="Resource_contention" title="Resource contention">contention</a></i>: this occurs whenever one process or thread attempts to acquire a lock held by another process or thread. The more fine-grained the available locks, the less likely one process/thread will request a lock held by the other. (For example, locking a row rather than the entire table, or locking a cell rather than the entire row);</li>
<li><i><a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlock</a></i>: the situation when each of at least two tasks is waiting for a lock that the other task holds. Unless something is done, the two tasks will wait forever.</li></ul>
<p>There is a tradeoff between decreasing lock overhead and decreasing lock contention when choosing the number of locks in synchronization.
</p><p>An important property of a lock is its <i><a href="Granularity_(parallel_computing)" title="Granularity (parallel computing)">granularity</a></i>. The granularity is a measure of the amount of data the lock is protecting. In general, choosing a coarse granularity (a small number of locks, each protecting a large segment of data) results in less <i>lock overhead</i> when a single process is accessing the protected data, but worse performance when multiple processes are running concurrently. This is because of increased <i>lock contention</i>. The more coarse the lock, the higher the likelihood that the lock will stop an unrelated process from proceeding. Conversely, using a fine granularity (a larger number of locks, each protecting a fairly small amount of data) increases the overhead of the locks themselves but reduces lock contention. Granular locking where each process must hold multiple locks from a common set of locks can create subtle lock dependencies. This subtlety can increase the chance that a programmer will unknowingly introduce a <i>deadlock</i>.
</p><p>In a <a href="Database_management_system" class="mw-redirect" title="Database management system">database management system</a>, for example, a lock could protect, in order of decreasing granularity, part of a field, a field, a record, a data page, or an entire table. Coarse granularity, such as using table locks, tends to give the best performance for a single user, whereas fine granularity, such as record locks, tends to give the best performance for multiple users.
</p>
<div class="mw-heading mw-heading2"><h2 id="Database_locks">Database locks</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Lock_(database)" class="mw-redirect" title="Lock (database)">Lock (database)</a></div>
<p><a href="Lock_(database)" class="mw-redirect" title="Lock (database)">Database locks</a> can be used as a means of ensuring transaction synchronicity. i.e. when making transaction processing concurrent (interleaving transactions), using <a href="Two-phase_locking" title="Two-phase locking">2-phased locks</a> ensures that the concurrent execution of the transaction turns out equivalent to some serial ordering of the transaction. However, deadlocks become an unfortunate side-effect of locking in databases. Deadlocks are either prevented by pre-determining the locking order between transactions or are detected using <a href="Wait-for_graph" title="Wait-for graph">waits-for graphs</a>. An alternate to locking for database synchronicity while avoiding deadlocks involves the use of totally ordered global timestamps.
</p><p>There are mechanisms employed to manage the actions of multiple <a href="Concurrent_user" title="Concurrent user">concurrent users</a> on a database—the purpose is to prevent lost updates and dirty reads. The two types of locking are <i>pessimistic locking</i> and <i>optimistic locking</i>:
</p>
<ul><li><i>Pessimistic locking</i>: a user who reads a record with the intention of updating it places an exclusive lock on the record to prevent other users from manipulating it. This means no one else can manipulate that record until the user releases the lock. The downside is that users can be locked out for a very long time, thereby slowing the overall system response and causing frustration.</li></ul>
<dl><dd><dl><dd>Where to use pessimistic locking: this is mainly used in environments where data-contention (the degree of users request to the database system at any one time) is heavy; where the cost of protecting data through locks is less than the cost of rolling back transactions, if concurrency conflicts occur. Pessimistic concurrency is best implemented when lock times will be short, as in programmatic processing of records. Pessimistic concurrency requires a persistent connection to the database and is not a scalable option when users are interacting with data, because records might be locked for relatively large periods of time. It is not appropriate for use in Web application development.</dd></dl></dd></dl>
<ul><li><i><a href="Optimistic_locking" class="mw-redirect" title="Optimistic locking">Optimistic locking</a></i>: this allows multiple concurrent users access to the database whilst the system keeps a copy of the initial-read made by each user. When a user wants to update a record, the application determines whether another user has changed the record since it was last read. The application does this by comparing the initial-read held in memory to the database record to verify any changes made to the record. Any discrepancies between the initial-read and the database record violates concurrency rules and hence causes the system to disregard any update request. An error message is generated and the user is asked to start the update process again. It improves database performance by reducing the amount of locking required, thereby reducing the load on the database server. It works efficiently with tables that require limited updates since no users are locked out. However, some updates may fail. The downside is constant update failures due to high volumes of update requests from multiple concurrent users - it can be frustrating for users.</li></ul>
<dl><dd><dl><dd>Where to use optimistic locking: this is appropriate in environments where there is low contention for data, or where read-only access to data is required. Optimistic concurrency is used extensively in .NET to address the needs of mobile and disconnected applications,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> where locking data rows for prolonged periods of time would be infeasible. Also, maintaining record locks requires a persistent connection to the database server, which is not possible in disconnected applications.</dd></dl></dd></dl>
<div class="mw-heading mw-heading2"><h2 id="Lock_compatibility_table">Lock compatibility table</h2></div>
<p>Several variations and refinements of these major lock types exist, with respective variations of blocking behavior. If a first lock blocks another lock, the two locks are called <i>incompatible</i>; otherwise the locks are <i>compatible</i>. Often, lock types blocking interactions are presented in the technical literature by a <i>Lock compatibility table</i>. The following is an example with the common, major lock types:
</p>
<table class="wikitable" style="text-align:center;">
<caption>Lock compatibility table
</caption>
<tbody><tr>
<th>Lock type</th>
<th>read-lock</th>
<th>write-lock
</th></tr>
<tr>
<th>read-lock
</th>
<td><b>✔</b></td>
<td><b>X</b>
</td></tr>
<tr>
<th>write-lock
</th>
<td><b>X</b></td>
<td><b>X</b>
</td></tr></tbody></table>
<ul><li><b>✔</b> indicates compatibility</li>
<li><b>X</b> indicates incompatibility, i.e., a case when a lock of the first type (in left column) on an object blocks a lock of the second type (in top row) from being acquired on the same object (by another transaction). An object typically has a queue of waiting requested (by transactions) operations with respective locks. The first blocked lock for operation in the queue is acquired as soon as the existing blocking lock is removed from the object, and then its respective operation is executed. If a lock for operation in the queue is not blocked by any existing lock (existence of multiple compatible locks on a same object is possible concurrently), it is acquired immediately.</li></ul>
<p><b>Comment:</b> In some publications, the table entries are simply marked "compatible" or "incompatible", or respectively "yes" or "no".<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Disadvantages">Disadvantages</h2></div>
<p>Lock-based resource protection and thread/process synchronization have many disadvantages:
</p>
<ul><li>Contention: some threads/processes have to wait until a lock (or a whole set of locks) is released. If one of the threads holding a lock dies, stalls, blocks, or enters an infinite loop, other threads waiting for the lock may wait indefinitely until the computer is <a href="Power_cycling" title="Power cycling">power cycled</a>.</li>
<li>Overhead: the use of locks adds overhead for each access to a resource, even when the chances for collision are very rare. (However, any chance for such collisions is a <a href="Race_condition" title="Race condition">race condition</a>.)</li>
<li>Debugging: bugs associated with locks are time dependent and can be very subtle and extremely hard to replicate, such as <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlocks</a>.</li>
<li>Instability: the optimal balance between lock overhead and lock contention can be unique to the problem domain (application) and sensitive to design, implementation, and even low-level system architectural changes. These balances may change over the life cycle of an application and may entail tremendous changes to update (re-balance).</li>
<li>Composability: locks are only composable (e.g., managing multiple concurrent locks in order to atomically delete item X from table A and insert X into table B) with relatively elaborate (overhead) software support and perfect adherence by applications programming to rigorous conventions.</li>
<li><a href="Priority_inversion" title="Priority inversion">Priority inversion</a>: a low-priority thread/process holding a common lock can prevent high-priority threads/processes from proceeding. <a href="Priority_inheritance" title="Priority inheritance">Priority inheritance</a> can be used to reduce priority-inversion duration. The <a href="Priority_ceiling_protocol" title="Priority ceiling protocol">priority ceiling protocol</a> can be used on uniprocessor systems to minimize the worst-case priority-inversion duration, as well as prevent <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlock</a>.</li>
<li><a href="Lock_convoy" title="Lock convoy">Convoying</a>: all other threads have to wait if a thread holding a lock is descheduled due to a time-slice interrupt or page fault.</li></ul>
<p>Some <a href="Concurrency_control" title="Concurrency control">concurrency control</a> strategies avoid some or all of these problems. For example, a <a href="Funnel_(Concurrent_computing)" class="mw-redirect" title="Funnel (Concurrent computing)">funnel</a> or <a href="Serializing_tokens" title="Serializing tokens">serializing tokens</a> can avoid the biggest problem: deadlocks. Alternatives to locking include <a href="Non-blocking_synchronization" class="mw-redirect" title="Non-blocking synchronization">non-blocking synchronization</a> methods, like <a href="Lock-free_and_wait-free_algorithms" class="mw-redirect" title="Lock-free and wait-free algorithms">lock-free</a> programming techniques and <a href="Transactional_memory" title="Transactional memory">transactional memory</a>. However, such alternative methods often require that the actual lock mechanisms be implemented at a more fundamental level of the operating software. Therefore, they may only relieve the <i>application</i> level from the details of implementing locks, with the problems listed above still needing to be dealt with beneath the application.
</p><p>In most cases, proper locking depends on the CPU providing a method of atomic instruction stream synchronization (for example, the addition or deletion of an item into a pipeline requires that all contemporaneous operations needing to add or delete other items in the pipe be suspended during the manipulation of the memory content required to add or delete the specific item). Therefore, an application can often be more robust when it recognizes the burdens it places upon an operating system and is capable of graciously recognizing the reporting of impossible demands.
</p>
<div class="mw-heading mw-heading3"><h3 id="Lack_of_composability">Lack of composability</h3></div>
<p>One of lock-based programming's biggest problems is that "locks don't <a href="Function_composition_(computer_science)" title="Function composition (computer science)">compose</a>": it is hard to combine small, correct lock-based modules into equally correct larger programs without modifying the modules or at least knowing about their internals. <a href="Simon_Peyton_Jones" title="Simon Peyton Jones">Simon Peyton Jones</a> (an advocate of <a href="Software_transactional_memory" title="Software transactional memory">software transactional memory</a>) gives the following example of a banking application:<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> design a class <span class="monospaced">Account</span> that allows multiple concurrent clients to deposit or withdraw money to an account, and give an algorithm to transfer money from one account to another.
</p><p>The lock-based solution to the first part of the problem is:
</p>
<pre><b>class</b> Account:
<b>member</b> balance: Integer
<b>member</b> mutex: Lock

<b>method</b> deposit(n: Integer)
mutex.lock()
balance ← balance + n
mutex.unlock()

<b>method</b> withdraw(n: Integer)
deposit(−n)
</pre>
<p>The second part of the problem is much more complicated. A <span class="monospaced">transfer</span> routine that is correct <i>for sequential programs</i> would be
</p>
<pre><b>function</b> transfer(from: Account, to: Account, amount: Integer)
from.withdraw(amount)
to.deposit(amount)
</pre>
<p>In a concurrent program, this algorithm is incorrect because when one thread is halfway through <span class="monospaced">transfer</span>, another might observe a state where <span class="monospaced">amount</span> has been withdrawn from the first account, but not yet deposited into the other account: money has gone missing from the system. This problem can only be fixed completely by putting locks on both accounts prior to changing either one, but then the locks have to be placed according to some arbitrary, global ordering to prevent deadlock:
</p>
<pre><b>function</b> transfer(from: Account, to: Account, amount: Integer)
<b>if</b> from &lt; to <i>// arbitrary ordering on the locks</i>
from.lock()
to.lock()
<b>else</b>
to.lock()
from.lock()
from.withdraw(amount)
to.deposit(amount)
from.unlock()
to.unlock()
</pre>
<p>This solution gets more complicated when more locks are involved, and the <span class="monospaced">transfer</span> function needs to know about all of the locks, so they cannot be <a href="Encapsulation_(object-oriented_programming)" class="mw-redirect" title="Encapsulation (object-oriented programming)">hidden</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2></div>
<div role="note" class="hatnote navigation-not-searchable">See also: <a href="Barrier_(computer_science)" title="Barrier (computer science)">Barrier (computer science)</a></div>
<p>Programming languages vary in their support for synchronization:
</p>
<ul><li><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a> provides protected objects that have visible protected subprograms or entries<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> as well as rendezvous.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup></li>
<li>The ISO/IEC <a href="C_(programming_language)" title="C (programming language)">C</a> standard provides a standard <a href="Mutual_exclusion" title="Mutual exclusion">mutual exclusion</a> (locks) <a href="Application_programming_interface" class="mw-redirect" title="Application programming interface">application programming interface</a> (API) since <a href="C11_(C_standard_revision)" title="C11 (C standard revision)">C11</a>. The current ISO/IEC <a href="C%2B%2B" title="C++">C++</a> standard supports <a href="C%2B%2B0x" class="mw-redirect" title="C++0x">threading facilities</a> since <a href="C%2B%2B11" title="C++11">C++11</a>. The <a href="OpenMP" title="OpenMP">OpenMP</a> standard is supported by some compilers, and allows <a href="Critical_sections" class="mw-redirect" title="Critical sections">critical sections</a> to be specified using pragmas. The <a href="POSIX_Threads" class="mw-redirect" title="POSIX Threads">POSIX pthread</a> API provides lock support.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> <a href="Visual_C%2B%2B" class="mw-redirect" title="Visual C++">Visual C++</a> provides the <code>synchronize</code> attribute of methods to be synchronized, but this is specific to COM objects in the <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> architecture and <a href="Visual_C%2B%2B" class="mw-redirect" title="Visual C++">Visual C++</a> compiler.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> C and C++ can easily access any native operating system locking features.</li>
<li><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> provides the <code>lock</code> keyword on a thread to ensure its exclusive access to a resource.</li>
<li><a href="Visual_Basic_(.NET)" title="Visual Basic (.NET)">Visual Basic (.NET)</a> provides a <code>SyncLock</code> keyword like C#'s <code>lock</code> keyword.</li>
<li><a href="Java_(programming_language)" title="Java (programming language)">Java</a> provides the keyword <code>synchronized</code> to lock code blocks, <a href="Method_(computer_programming)" title="Method (computer programming)">methods</a> or <a href="Object_(computer_science)" title="Object (computer science)">objects</a><sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> and libraries featuring concurrency-safe data structures.</li>
<li><a href="Objective-C" title="Objective-C">Objective-C</a> provides the keyword <code>@synchronized</code><sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> to put locks on blocks of code and also provides the <a href="Class_(computer_programming)" title="Class (computer programming)">classes</a> NSLock,<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> NSRecursiveLock,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> and NSConditionLock<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup> along with the NSLocking protocol<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup> for locking as well.</li>
<li><a href="PHP" title="PHP">PHP</a> provides a file-based locking <sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> as well as a <code>Mutex</code> class in the <code>pthreads</code> extension.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Python_(programming_language)" title="Python (programming language)">Python</a> provides a low-level <a href="Mutual_exclusion" title="Mutual exclusion">mutex</a> mechanism with a <code>Lock</code> <a href="Class_(computer_programming)" title="Class (computer programming)">class</a> from the <code>threading</code> module.<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup></li>
<li>The ISO/IEC <a href="Fortran" title="Fortran">Fortran</a> standard (ISO/IEC 1539-1:2010) provides the <code>lock_type</code> derived type in the intrinsic module <code>iso_fortran_env</code> and the <code>lock</code>/<code>unlock</code> statements since <a href="Fortran#Fortran_2008" title="Fortran">Fortran 2008</a>.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> provides a low-level <a href="Mutual_exclusion" title="Mutual exclusion">mutex</a> object and no keyword.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a> provides the <code>Mutex&lt;T&gt;</code><sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> struct.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup></li>
<li><a href="X86_assembly_language" title="X86 assembly language">x86 assembly language</a> provides the <code>LOCK</code> prefix on certain operations to guarantee their atomicity.</li>
<li><a href="Haskell" title="Haskell">Haskell</a> implements locking via a mutable data structure called an <code>MVar</code>, which can either be empty or contain a value, typically a reference to a resource. A thread that wants to use the resource ‘takes’ the value of the <code>MVar</code>, leaving it empty, and puts it back when it is finished. Attempting to take a resource from an empty <code>MVar</code> results in the thread blocking until the resource is available.<sup id="cite_ref-marlow_conc_haskell_24-0" class="reference"><a href="#cite_note-marlow_conc_haskell-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> As an alternative to locking, an implementation of <a href="Software_transactional_memory" title="Software transactional memory">software transactional memory</a> also exists.<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Go_(programming_language)" title="Go (programming language)">Go</a> provides a low-level <a href="Mutual_exclusion" title="Mutual exclusion">Mutex</a> object in standard's library <a rel="nofollow" class="external text" href="https://pkg.go.dev/sync">sync</a> package.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup> It can be used for locking code blocks, <a href="Method_(computer_programming)" title="Method (computer programming)">methods</a> or <a href="Object_(computer_science)" title="Object (computer science)">objects</a>.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Mutexes_vs._semaphores">Mutexes vs. semaphores</h2></div>
<div class="excerpt-block"><style data-mw-deduplicate="TemplateStyles:r1066933788">
/* start https://en.wikipedia.org/ */


.mw-parser-output .excerpt-hat .mw-editsection-like{font-style:normal}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable dablink excerpt-hat selfref">This section is an excerpt from <a href="Semaphore_(programming)#Semaphores_vs._mutexes" title="Semaphore (programming)">Semaphore (programming) § Semaphores vs. mutexes</a>.<span class="mw-editsection-like "><span class="mw-editsection-bracket">[</span><a class="external text external" href="https://en.wikipedia.org/w/index.php?title=Semaphore_(programming)&amp;action=edit#Semaphores_vs._mutexes">edit</a><span class="mw-editsection-bracket">]</span></span></div><div class="excerpt">
<p>A <a href="Mutex" class="mw-redirect" title="Mutex">mutex</a> is a <a href="Mutual_exclusion#Types_of_mutual_exclusion_devices" title="Mutual exclusion">locking mechanism</a> that sometimes uses the same basic implementation as the binary semaphore. However, they differ in how they are used. While a binary semaphore may be colloquially referred to as a mutex, a true mutex has a more specific use-case and definition, in that only the <a href="Task_(computing)" title="Task (computing)">task</a> that locked the mutex is supposed to unlock it. This constraint aims to handle some potential problems of using semaphores:
</p>
<ol><li><a href="Priority_inversion" title="Priority inversion">Priority inversion</a>: If the mutex knows who locked it and is supposed to unlock it, it is possible to promote the priority of that task whenever a higher-priority task starts waiting on the mutex.</li>
<li>Premature task termination: Mutexes may also provide deletion safety, where the task holding the mutex cannot be accidentally deleted. (This is also a cost; if the mutex can prevent a task from being reclaimed, then a garbage collector has to monitor the mutex.)</li>
<li>Termination deadlock: If a mutex-holding task terminates for any reason, the <a href="Real-time_operating_system" title="Real-time operating system">OS</a> can release the mutex and signal waiting tasks of this condition.</li>
<li>Recursion deadlock: a task is allowed to lock a <a href="Reentrant_mutex" title="Reentrant mutex">reentrant mutex</a> multiple times as it unlocks it an equal number of times.</li>
<li>Accidental release: An error is raised on the release of the mutex if the releasing task is not its owner.</li></ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Critical_section" title="Critical section">Critical section</a></li>
<li><a href="Double-checked_locking" title="Double-checked locking">Double-checked locking</a></li>
<li><a href="File_locking" title="File locking">File locking</a></li>
<li><a href="Lock-free_and_wait-free_algorithms" class="mw-redirect" title="Lock-free and wait-free algorithms">Lock-free and wait-free algorithms</a></li>
<li><a href="Monitor_(synchronization)" title="Monitor (synchronization)">Monitor (synchronization)</a></li>
<li><a href="Mutual_exclusion" title="Mutual exclusion">Mutual exclusion</a></li>
<li><a href="Read/write_lock_pattern" class="mw-redirect" title="Read/write lock pattern">Read/write lock pattern</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-columns references-column-width reflist-columns-2">
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-us/library/c5kehkcz(v=vs.100).aspx">"lock Statement (C# Reference)"</a>. 4 February 2013.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text">
<cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-us/magazine/cc163896.aspx">"ThreadPoolPriority, and MethodImplAttribute"</a>. MSDN. p.&nbsp;??<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-11-22</span></span>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">
<cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://archive.today/20130102015335/http://www.25hoursaday.com/CsharpVsJava.html">"C# From a Java Developer's Perspective"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.25hoursaday.com/CsharpVsJava.html#attributes">the original</a> on 2013-01-02<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-11-22</span></span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080508154329/http://msdn.microsoft.com/en-us/library/ms978496.aspx">"Designing Data Tier Components and Passing Data Through Tiers"</a>. <a href="Microsoft" title="Microsoft">Microsoft</a>. August 2002. Archived from <a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/ms978496.aspx">the original</a> on 2008-05-08<span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-30</span></span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.geeksforgeeks.org/lock-based-concurrency-control-protocol-in-dbms/">"Lock Based Concurrency Control Protocol in DBMS"</a>. <i>GeeksforGeeks</i>. 2018-03-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-12-28</span></span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFPeyton_Jones2007" class="citation encyclopaedia cs1">Peyton Jones, Simon (2007). <a rel="nofollow" class="external text" href="https://research.microsoft.com/en-us/um/people/simonpj/papers/stm/beautiful.pdf">"Beautiful concurrency"</a> <span class="cs1-format">(PDF)</span>. In Wilson, Greg; Oram, Andy (eds.). <i>Beautiful Code: Leading Programmers Explain How They Think</i>. O'Reilly.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite id="CITEREFISO/IEC_8652:2007" class="citation book cs1">ISO/IEC 8652:2007. <a rel="nofollow" class="external text" href="http://www.adaic.com/standards/1zrm/html/RM-9-4.html">"Protected Units and Protected Objects"</a>. <i>Ada&nbsp;2005 Reference Manual</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2010-02-27</span></span>. <q>A protected object provides coordinated access to shared data, through calls on its visible protected operations, which can be protected subprograms or protected entries.</q></cite><span class="cs1-maint citation-comment"><code class="cs1-code">{{cite book}}</code>: CS1 maint: numeric names: authors list (link)</span></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFISO/IEC_8652:2007" class="citation book cs1">ISO/IEC 8652:2007. <a rel="nofollow" class="external text" href="http://www.adaic.com/standards/1zrm/html/RM-9-11.html">"Example of Tasking and Synchronization"</a>. <i>Ada&nbsp;2005 Reference Manual</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2010-02-27</span></span>.</cite><span class="cs1-maint citation-comment"><code class="cs1-code">{{cite book}}</code>: CS1 maint: numeric names: authors list (link)</span></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite id="CITEREFMarshall1999" class="citation web cs1">Marshall, Dave (March 1999). <a rel="nofollow" class="external text" href="https://www.cs.cf.ac.uk/Dave/C/node31.html#SECTION003110000000000000000">"Mutual Exclusion Locks"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-30</span></span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-us/library/34d2s8k3(VS.80).aspx">"Synchronize"</a>. msdn.microsoft.com<span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-30</span></span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html">"Synchronization"</a>. <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-30</span></span>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html">"Apple Threading Reference"</a>. Apple, inc<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-10-17</span></span>.</cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSLock_Class/Reference/Reference.html">"NSLock Reference"</a>. Apple, inc<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-10-17</span></span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSRecursiveLock_Class/Reference/Reference.html">"NSRecursiveLock Reference"</a>. Apple, inc<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-10-17</span></span>.</cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSConditionLock_Class/Reference/Reference.html">"NSConditionLock Reference"</a>. Apple, inc<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-10-17</span></span>.</cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSLocking_Protocol/Reference/Reference.html">"NSLocking Protocol Reference"</a>. Apple, inc<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-10-17</span></span>.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://php.net/manual/en/function.flock.php">"flock"</a>.</cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20170704152552/http://php.net/manual/en/class.mutex.php">"The Mutex class"</a>. Archived from <a rel="nofollow" class="external text" href="http://php.net/manual/en/class.mutex.php">the original</a> on 2017-07-04<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-12-29</span></span>.</cite></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><cite id="CITEREFLundh2007" class="citation web cs1">Lundh, Fredrik (July 2007). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201101025814/http://effbot.org/zone/thread-synchronization.htm">"Thread Synchronization Mechanisms in Python"</a>. Archived from <a rel="nofollow" class="external text" href="http://effbot.org/zone/thread-synchronization.htm">the original</a> on 2020-11-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-30</span></span>.</cite></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite id="CITEREFJohn_Reid2010" class="citation web cs1">John Reid (2010). <a rel="nofollow" class="external text" href="https://wg5-fortran.org/N1801-N1850/N1824.pdf">"Coarrays in the next Fortran Standard"</a> <span class="cs1-format">(PDF)</span><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-02-17</span></span>.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.ruby-lang.org/en/master/Thread/Mutex.html">"class Thread::Mutex"</a>.</cite></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/std/sync/struct.Mutex.html">"std::sync::Mutex - Rust"</a>. <i>doc.rust-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">3 November</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/book/ch16-03-shared-state.html">"Shared-State Concurrency - The Rust Programming Language"</a>. <i>doc.rust-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">3 November</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-marlow_conc_haskell-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-marlow_conc_haskell_24-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFMarlow2013" class="citation book cs1"><a href="Simon_Marlow" title="Simon Marlow">Marlow, Simon</a> (August 2013). "Basic concurrency: threads and MVars". <a rel="nofollow" class="external text" href="https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/"><i>Parallel and Concurrent Programming in Haskell</i></a>. <a href="O%E2%80%99Reilly_Media" class="mw-redirect" title="O’Reilly Media">O’Reilly Media</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781449335946</bdi>.</cite></span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><cite id="CITEREFMarlow2013" class="citation book cs1"><a href="Simon_Marlow" title="Simon Marlow">Marlow, Simon</a> (August 2013). "Software transactional memory". <a rel="nofollow" class="external text" href="https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/"><i>Parallel and Concurrent Programming in Haskell</i></a>. <a href="O%E2%80%99Reilly_Media" class="mw-redirect" title="O’Reilly Media">O’Reilly Media</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781449335946</bdi>.</cite></span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://pkg.go.dev/sync#Mutex">"sync package - sync - pkg.go.dev"</a>. <i>pkg.go.dev</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-11-23</span></span>.</cite></span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110620203242/http://www.futurechips.org/tips-for-power-coders/parallel-programming-understanding-impact-critical-sections.html">Tutorial on Locks and Critical Sections</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Software_design_patterns225" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Software_design_patterns225" style="font-size:114%;margin:0 4em"><a href="Software_design_pattern" title="Software design pattern">Software design patterns</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Design_Patterns" title="Design Patterns">Gang of Four<br>patterns</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Creational_pattern" title="Creational pattern">Creational</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Abstract_factory_pattern" title="Abstract factory pattern">Abstract factory</a></li>
<li><a href="Builder_pattern" title="Builder pattern">Builder</a></li>
<li><a href="Factory_method_pattern" title="Factory method pattern">Factory method</a></li>
<li><a href="Prototype_pattern" title="Prototype pattern">Prototype</a></li>
<li><a href="Singleton_pattern" title="Singleton pattern">Singleton</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Structural_pattern" title="Structural pattern">Structural</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Adapter_pattern" title="Adapter pattern">Adapter</a></li>
<li><a href="Bridge_pattern" title="Bridge pattern">Bridge</a></li>
<li><a href="Composite_pattern" title="Composite pattern">Composite</a></li>
<li><a href="Decorator_pattern" title="Decorator pattern">Decorator</a></li>
<li><a href="Facade_pattern" title="Facade pattern">Facade</a></li>
<li><a href="Flyweight_pattern" title="Flyweight pattern">Flyweight</a></li>
<li><a href="Proxy_pattern" title="Proxy pattern">Proxy</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Behavioral_pattern" title="Behavioral pattern">Behavioral</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chain-of-responsibility_pattern" title="Chain-of-responsibility pattern">Chain of responsibility</a></li>
<li><a href="Command_pattern" title="Command pattern">Command</a></li>
<li><a href="Interpreter_pattern" title="Interpreter pattern">Interpreter</a></li>
<li><a href="Iterator_pattern" title="Iterator pattern">Iterator</a></li>
<li><a href="Mediator_pattern" title="Mediator pattern">Mediator</a></li>
<li><a href="Memento_pattern" title="Memento pattern">Memento</a></li>
<li><a href="Observer_pattern" title="Observer pattern">Observer</a></li>
<li><a href="State_pattern" title="State pattern">State</a></li>
<li><a href="Strategy_pattern" title="Strategy pattern">Strategy</a></li>
<li><a href="Template_method_pattern" title="Template method pattern">Template method</a></li>
<li><a href="Visitor_pattern" title="Visitor pattern">Visitor</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Concurrency_pattern" title="Concurrency pattern">Concurrency<br>patterns</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Active_object" title="Active object">Active object</a></li>
<li><a href="Balking_pattern" title="Balking pattern">Balking</a></li>
<li><a href="Binding_properties_pattern" title="Binding properties pattern">Binding properties</a></li>
<li><a href="Double-checked_locking" title="Double-checked locking">Double-checked locking</a></li>
<li><a href="Asynchronous_method_invocation" title="Asynchronous method invocation">Event-based asynchronous</a></li>
<li><a href="Guarded_suspension" title="Guarded suspension">Guarded suspension</a></li>
<li><a href="Join-pattern" title="Join-pattern">Join</a></li>

<li><a href="Monitor_(synchronization)" title="Monitor (synchronization)">Monitor</a></li>
<li><a href="Proactor_pattern" title="Proactor pattern">Proactor</a></li>
<li><a href="Reactor_pattern" title="Reactor pattern">Reactor</a></li>
<li><a href="Readers%E2%80%93writer_lock" title="Readers–writer lock">Read–write lock</a></li>
<li><a href="Scheduler_pattern" class="mw-redirect" title="Scheduler pattern">Scheduler</a></li>
<li><a href="Scheduled-task_pattern" title="Scheduled-task pattern">Scheduled-task pattern</a></li>
<li><a href="Semaphore_(programming)" title="Semaphore (programming)">Semaphore</a></li>
<li><a href="Thread_pool" title="Thread pool">Thread pool</a></li>
<li><a href="Thread-local_storage" title="Thread-local storage">Thread-local storage</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Architectural_pattern" title="Architectural pattern">Architectural<br>patterns</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Front_controller" title="Front controller">Front controller</a></li>
<li><a href="Interceptor_pattern" title="Interceptor pattern">Interceptor</a></li>
<li><a href="Model%E2%80%93view%E2%80%93controller" title="Model–view–controller">MVC</a>
<ul><li><a href="Model%E2%80%93view%E2%80%93presenter" title="Model–view–presenter">MVP</a></li>
<li><a href="Model%E2%80%93view%E2%80%93viewmodel" title="Model–view–viewmodel">MVVM</a></li></ul></li>
<li><a href="Action%E2%80%93domain%E2%80%93responder" title="Action–domain–responder">ADR</a></li>
<li><a href="Entity_component_system" title="Entity component system">ECS</a></li>
<li><a href="Multitier_architecture" title="Multitier architecture"><i>n</i>-tier</a></li>
<li><a href="Specification_pattern" title="Specification pattern">Specification</a></li>
<li><a href="Publish%E2%80%93subscribe_pattern" title="Publish–subscribe pattern">Publish–subscribe</a></li>
<li><a href="Naked_objects" title="Naked objects">Naked objects</a></li>
<li><a href="Service_locator_pattern" title="Service locator pattern">Service locator</a></li>
<li><a href="Active_record_pattern" title="Active record pattern">Active record</a></li>
<li><a href="Identity_map_pattern" title="Identity map pattern">Identity map</a></li>
<li><a href="Data_access_object" title="Data access object">Data access object</a></li>
<li><a href="Data_transfer_object" title="Data transfer object">Data transfer object</a></li>
<li><a href="Inversion_of_control" title="Inversion of control">Inversion of control</a></li>
<li><a href="JSP_model_2_architecture" title="JSP model 2 architecture">Model 2</a></li>
<li><a href="Broker_pattern" title="Broker pattern">Broker</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other<br>patterns</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Blackboard_design_pattern" class="mw-redirect" title="Blackboard design pattern">Blackboard</a></li>
<li><a href="Business_delegate_pattern" title="Business delegate pattern">Business delegate</a></li>
<li><a href="Composite_entity_pattern" title="Composite entity pattern">Composite entity</a></li>
<li><a href="Dependency_injection" title="Dependency injection">Dependency injection</a></li>
<li><a href="Guard_(computer_science)" title="Guard (computer science)">Guard clause</a></li>
<li><a href="Intercepting_filter_pattern" title="Intercepting filter pattern">Intercepting filter</a></li>
<li><a href="Lazy_loading" title="Lazy loading">Lazy loading</a></li>
<li><a href="Mock_object" title="Mock object">Mock object</a></li>
<li><a href="Null_object_pattern" title="Null object pattern">Null object</a></li>
<li><a href="Object_pool_pattern" title="Object pool pattern">Object pool</a></li>
<li><a href="Servant_(design_pattern)" title="Servant (design pattern)">Servant</a></li>
<li><a href="Twin_pattern" title="Twin pattern">Twin</a></li>
<li><a href="Type_Tunnel_pattern" class="mw-redirect" title="Type Tunnel pattern">Type tunnel</a></li>
<li><a href="Method_chaining" title="Method chaining">Method chaining</a></li>
<li><a href="Delegation_pattern" title="Delegation pattern">Delegation</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Books</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><i><a href="Design_Patterns" title="Design Patterns">Design Patterns</a></i></li>
<li><i><a href="Enterprise_Integration_Patterns" title="Enterprise Integration Patterns">Enterprise Integration Patterns</a></i></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">People</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Christopher_Alexander" title="Christopher Alexander">Christopher Alexander</a></li>
<li><a href="Erich_Gamma" title="Erich Gamma">Erich Gamma</a></li>
<li><a href="Ralph_Johnson_(computer_scientist)" title="Ralph Johnson (computer scientist)">Ralph Johnson</a></li>
<li><a href="John_Vlissides" title="John Vlissides">John Vlissides</a></li>
<li><a href="Grady_Booch" title="Grady Booch">Grady Booch</a></li>
<li><a href="Kent_Beck" title="Kent Beck">Kent Beck</a></li>
<li><a href="Ward_Cunningham" title="Ward Cunningham">Ward Cunningham</a></li>
<li><a href="Martin_Fowler_(software_engineer)" title="Martin Fowler (software engineer)">Martin Fowler</a></li>
<li><a href="Robert_C._Martin" title="Robert C. Martin">Robert Martin</a></li>
<li><a href="Jim_Coplien" title="Jim Coplien">Jim Coplien</a></li>
<li><a href="Douglas_C._Schmidt" title="Douglas C. Schmidt">Douglas Schmidt</a></li>
<li><a href="Linda_Rising" title="Linda Rising">Linda Rising</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Communities</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="The_Hillside_Group" title="The Hillside Group">The Hillside Group</a></li>
<li><a href="Portland_Pattern_Repository" title="Portland Pattern Repository">Portland Pattern Repository</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">See also</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Anti-pattern" title="Anti-pattern">Anti-pattern</a></li>
<li><a href="Architectural_pattern" title="Architectural pattern">Architectural pattern</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-06-11" href="https://en.wikipedia.org/wiki/?title=Lock_(computer_science)&amp;oldid=1295039077">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>